#{extends 'CRUD/layout.html' /}
#{set title:messages.get('medicineCards') /}

<script>
$(document).ready(function(){
	$("tbody tr td").each(function() {
		var link = $(this).find('.hiddenLinks').text();
		$(this).click(function(){
			$(location).attr("href", link);
		});
		$(this).hover(function () {
		    $(this).addClass("hover");
		  },
		  function () {
		    $(this).removeClass("hover");
		  });
	});
});
</script>

<div id="crudList" class="${type.name}">

    <h2 id="crudListTitle">&{'medicineCards'}</h2>

    <div id="crudListTable">
	    <table>
		    <thead>
		        <tr>
		           <th>
		               <span>&{'patient'}</span>
		           </th>
		           <th>
		               <span>&{'creationDate'}</span>
		           </th>
		           <th>
		               <span>&{'otherInfo'}</span>
		           </th>
		        </tr>
		    </thead>
		    <tbody>
		    #{list patients, as:'patient'}
			    <tr>
	               <td>
	               		<span class="hiddenLinks">@{Patients.show(patient.patientId)}</span>
	                    &{patient}
		   		   </td>
	               <td>
	               	   <span class="hiddenLinks">@{MedicineCards.show(patient.medicineCard.medicineCardId)}</span>
	                   &{patient.medicineCard.creationDate.format()}
		   		   </td>
	               <td class="hidden">
	               		<span class="hiddenLinks">@{MedicineCards.show(patient.medicineCard.medicineCardId)}</span>
                   		#{if patient.medicineCard.otherInfo != null }
	                   		&{patient.medicineCard.otherInfo}
						#{/if}
	               </td>
	            </tr>
			    #{/list}
		    </tbody>
	    
	    </table>
    </div>

    <div id="crudListPagination">
        &{'total', models.MedicineCard.count()}
    </div>
    
</div>